﻿using System.ComponentModel;
using Newtonsoft.Json;

namespace WebCommon.Api
{
    /// <summary>
    /// RetJson返回基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class RetBase
    {
        public RetBase()
        {
            
        }

        /// <summary>
        ///     消息
        /// </summary> 
        //[JsonProperty("msg")]
        [DisplayName("返回消息")]
        public string Msg { get; set; } = "";

        /// <summary>
        ///     状态
        /// </summary>
        //[JsonProperty("code")]
        [DisplayName("状态")]
        public string Code
        {
            get
            {  
                if (string.IsNullOrWhiteSpace(this.Msg))
                {
                    return "0";
                }
                if ("未登录" ==Msg)
                {
                    return "2";
                }
                else
                {
                    return "1";
                }
          
            }
        }

        /// <summary>
        ///     时间
        /// </summary>
        //[JsonProperty("time")]
        //[DisplayName("服务器时间")]
        //public string Time
        //{
        //    get
        //    {
        //        return DateTime.Now.ToString("yyyyMMddHHmmss");
        //    }
        //} 

        /// <summary>
        ///     时间
        /// </summary>
        //[JsonProperty("cachetimeout")]
        [DisplayName("服务器缓存时间")]
        public string CacheTimeOut { get; set; } = "0";
    }
}